package com.example.physicalexaminationsystem.controller;

import com.example.physicalexaminationsystem.dto.ResponseDto;
import com.example.physicalexaminationsystem.service.ProjectService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author shiwenzhuo
 * 
 * @description
 */
@RestController
@RequestMapping("/api/project")
public class ProjectController {
    @Resource
    private ProjectService projectService;

    //获取项目信息
    @RequestMapping("/getProjectList")
    public ResponseDto getProjectList() {
        return ResponseDto.success(projectService.getProjectList());
    }

    //添加项目信息
    @RequestMapping("/addProject")
    public ResponseDto addProject(@RequestBody Map<String, Object> params) {
        return projectService.addProject(params);
    }

    //删除项目信息根据id
    @RequestMapping("/deleteProjectById")
    public ResponseDto deleteProjectById(@RequestParam Long id) {
        projectService.deleteProjectById(id);
        return ResponseDto.success();
    }

    //修改项目信息
    @RequestMapping("/updateProject")
    public ResponseDto updateProject(@RequestBody Map<String, Object> params) {
        return projectService.updateProjectById(params);
    }
}
